home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / SPRINTF.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  17KB  |  909 lines

  1. StdGrp        group    StdLib, StdData
  2. ;
  3. StdData        segment    para public 'sldata'
  4. ;
  5. cr        equ    0dh
  6. ff        equ    0ch
  7. lf        equ    0ah
  8. tab        equ    09h
  9. bs        equ    08h
  10. ;
  11. RtnAdrs        equ    2[bp]
  12. ;
  13. ;
  14. ; sp_BufSize is a public variable so the user can adjust the size.
  15. ;
  16.         public    sp_BufSize
  17. sp_BufSize    dw    2048
  18. ;
  19. ;
  20. ;
  21. aindex        dw    ?
  22. aptr        dd    ?
  23. ;
  24. StdData        ends
  25. ;
  26. stdlib        segment    para public 'slcode'
  27.         assume    cs:StdGrp
  28. ;
  29.         extrn    sl_ISize:far, sl_ULSize:far
  30.         extrn    sl_LSize:far, sl_USize:far
  31.         extrn    sl_itoam:far, sl_free:far
  32.         extrn    sl_wtoam:far, sl_ltoam:far
  33.         extrn    sl_ultoam:far, sl_htoam:far
  34.         extrn    sl_utoam:far
  35.         extrn    sl_malloc:far, sl_realloc:far
  36. ;
  37. ;
  38. ;
  39. ; Sprintfm- Like the "C" routine by the same name.  Calling sequence:
  40. ;
  41. ;               call    sprintfm
  42. ;               db      "format string",0
  43. ;               dd      item1, item2, ..., itemn
  44. ;
  45. ; Just like the PRINTF routine except it performs an in-memory format
  46. ; operation rather than printing the data to the current output device.
  47. ; Returns a pointer to the formatted string in ES:DI.
  48. ; See the PRINTF routine for more details about this guy.
  49. ;
  50. ;
  51. ;
  52.         public    sl_sprintfm
  53. sl_sprintfm    proc    far
  54.         push    bp
  55.         mov    bp, sp
  56.         pushf
  57.         push    ax
  58.         push    cx
  59. ;
  60. ; Request some memory from the system.  If there isn't enough available,
  61. ; try half as much and repeat.  If there is no memory available, return
  62. ; with the carry set.
  63. ;
  64.         mov    cx, sp_BufSize
  65. TryAgain:    call    sl_malloc
  66.         jnc    DoSPRINTF
  67.         shr    cx, 1
  68.         cmp    cx, 128            ;Need at least 128 bytes.
  69.         jae    TryAgain
  70.         pop    cx
  71.         pop    ax
  72.         popf
  73.         pop    bp
  74.         stc
  75.         ret
  76. ;
  77. ; The following code simulates a far call to sprintf.  We can't make the
  78. ; call because we need to skip the MOV BP, SP instruction which appears
  79. ; at the beginning of the code.
  80. ;
  81. DoSPRINTF:         push    cs            ;Push fake return address
  82.         mov    ax, offset stdgrp:RA
  83.         push    ax
  84.         push    bp            ;Push stuff on stack
  85.         pushf
  86.         push    ax
  87.         push    bx
  88.         push    cx
  89.         push    dx
  90.         push    di
  91.         push    si
  92.         push    es
  93.         push    ds
  94.         jmp    sl_sbprintf2
  95. ;
  96. ; Return back to this point from sbprintf.
  97. ;
  98. RA:        push    di
  99.         mov    cx, 1
  100.         mov    al, ch
  101. FindLength:    cmp    al, es:[di]
  102.         jz    AtEnd
  103.         inc    cx
  104.         inc    di
  105.         jmp    FindLength
  106. ;
  107. AtEnd:        pop    di
  108.         call    sl_realloc
  109.         pop    cx
  110.         pop    ax
  111.         popf
  112.         pop    bp
  113.         clc
  114.         ret
  115. sl_sprintfm    endp
  116. ;
  117. ;
  118. ;
  119. ;
  120. ; SPRINTF- Like sprintfm except it doesn't allocate storage for the
  121. ; formatted string.  Instead, you must pass it the address of a suitable
  122. ; buffer in es:di.
  123. ;
  124. ;
  125.         public  sl_sprintf
  126. sl_sprintf    proc    far
  127.         push    bp
  128.         mov    bp, sp
  129.         pushf
  130.         push    ax
  131.         push    bx
  132.         push    cx
  133.         push    dx
  134.         push    di
  135.         push    si
  136.         push    es
  137.         push    ds
  138. ;
  139. ; Save ptr to buffer area.
  140. ;
  141. sl_sbprintf2    proc    near
  142. sl_sbprintf2    endp
  143.         mov    word ptr StdGrp:aptr, di
  144.         mov    word ptr StdGrp:aptr+2, es
  145.         mov    StdGrp:aindex, 0
  146. ;
  147. ; Get pointers to the return address (format string).
  148. ;
  149.         cld
  150.         les    di, RtnAdrs
  151.         lds    si, RtnAdrs
  152. ;
  153. ; Okay, search for the end of the format string.  After these instructions,
  154. ; di points just beyond the zero byte at the end of the format string.  This,
  155. ; of course, points at the first address beyond the format string.
  156. ;
  157.         mov    al, 0
  158.         mov    cx, 65535
  159.     repne    scasb
  160. ;
  161. PrintItems:    lodsb            ;Get char si points at.
  162.         cmp    al, 0        ;EOS?
  163.         jz    PrintfDone
  164.         cmp    al, "%"        ;Start of a format string?
  165.         jz    FmtItem
  166.         cmp    al, "\"        ;Escape character?
  167.         jnz    PrintIt
  168.         call    GetEscChar
  169. PrintIt:    call    PutIt
  170.         jmp    PrintItems
  171. ;
  172. FmtItem:    call    GetFmtItem    ;Process the format item here.
  173.         jmp    PrintItems
  174. ;
  175. PrintfDone:    mov    RtnAdrs, di    ;Put out new return address.
  176.         pop    ds
  177.         pop    es
  178.         pop    si
  179.         pop    di
  180.         pop    dx
  181.         pop    cx
  182.         pop    bx
  183.         pop    ax
  184.         pop    bp
  185.         popf
  186.         clc
  187.         ret
  188. sl_sprintf    endp
  189. ;
  190. ; GetEscChar- Handles items immediately following the escape character "\".
  191. ;
  192. ;    Special escape characters (upper/lower case is acceptable):
  193. ;
  194. ;        n    Newline (cr/lf)
  195. ;        t    tab
  196. ;        b    backspace
  197. ;        r    return
  198. ;        l    line feed
  199. ;        f    formfeed
  200. ;        \    \
  201. ;        %    &
  202. ;        0xhh    Char with hex character code hh.  Must have exactly
  203. ;            two hexadecimal digits.
  204. ;
  205. GetEscChar    proc    near
  206.         lodsb            ;Get next character
  207.         cmp    al, 'n'
  208.         je    RtnNL
  209.         cmp    al, 'N'
  210.         je    RtnNL
  211.         cmp    al, 't'
  212.         je    RtnTab
  213.         cmp    al, 'T'
  214.         je    RtnTab
  215.         cmp    al, 'b'
  216.         je    RtnBS
  217.         cmp    al, 'B'
  218.         je    RtnBS
  219.         cmp    al, 'r'
  220.         je    RtnRtn
  221.         cmp    al, 'R'
  222.         je    RtnRtn
  223.         cmp    al, 'l'
  224.         je    RtnLF
  225.         cmp    al, 'L'
  226.         je    RtnLF
  227.         cmp    al, 'f'
  228.         je    RtnFF
  229.         cmp    al, 'F'
  230.         je    RtnFF
  231. ;
  232. ; Check for the presence of a 0xhh value here:
  233. ;
  234.         cmp    al, '0'
  235.         jne    RtnChar
  236.         cmp    byte ptr [si], 'x'
  237.         je    GetHex
  238.         cmp    byte ptr [si], 'X'
  239.         jne    RtnChar
  240. ;
  241. ; Okay, process the hex value here.  Note that exactly two hex digits must
  242. ; follow the 0x.
  243. ;
  244. GetHex:        inc    si        ;Point at first hex digit.
  245.         lodsb            ;Get first hex digit.
  246.         and    al, 05fh    ;l.c. -> u.c.
  247.         cmp    al, 'A'
  248.         jb    GotIt
  249.         sub    al, '7'
  250. GotIt:        shl    al, 1        ;Put into H.O. nibble.
  251.         shl    al, 1
  252.         shl    al, 1
  253.         shl    al, 1
  254.         mov    ah, al        ;Save for later
  255.         lodsb            ;Get next char.
  256.         and    al, 05fh
  257.         cmp    al, 'A'
  258.         jb    GotIt2
  259.         sub    al, '7'
  260. GotIt2:        and    al, 0fh
  261.         or    al, ah
  262.         ret            ;Return hex constant.
  263. ;
  264. ; RtnNL (return Newline) cheats.  It needs to return two characters.
  265. ; Since GetEscChar only returns a single character, this code goes ahead
  266. ; and calls putc to output the CR and the returns the LF.
  267. ;
  268. RtnNL:        mov    al, cr
  269.         call    PutIt
  270.         mov    al, lf
  271.         ret
  272. ;
  273. RtnTab:        mov    al, tab
  274.         ret
  275. ;
  276. RtnBS:        mov    al, bs
  277.         ret
  278. ;
  279. RtnRtn:        mov    al, cr
  280.         ret
  281. ;
  282. RtnLF:        mov    al, lf
  283.         ret
  284. ;
  285. RtnFF:        mov    al, ff
  286. RtnChar:    ret
  287. ;
  288. GetEscChar    endp
  289. ;
  290. ;
  291. ;
  292. GetFmtItem    proc    near
  293.         lodsb                ;Get char beyond "%"
  294. ;
  295.         mov    cx, 1            ;Default field width is 1.
  296.         mov    dl, 0            ;Default is right justified
  297.         mov    dh, ' '            ;Default fill char is space.
  298.         mov    ah, ' '            ;Assume straight ptr, not handle.
  299. ;
  300. ; See if the user wants the value left justified:
  301. ;
  302.         cmp    al, '-'
  303.         jne    NotLeftJust
  304.         inc    dl            ;Set to right justified
  305.         lodsb                ;Get next character.
  306. ;
  307. ; See if the user wants to change the padding character.
  308. ;
  309. NotLeftJust:    cmp    al, '\'
  310.         jne    NoPadChange
  311.         lodsb                ;Get Padding Character.
  312.         mov    dh, al            ;Save padding character.
  313.         lodsb                ;Get next character
  314. ;
  315. ; See if the user wants a different field width:
  316. ;
  317. NoPadChange:    cmp    al, '0'
  318.         jb    NoFldWidth
  319.         cmp    al, '9'
  320.         ja    NoFldWidth
  321.         call    GetDecVal
  322. ;
  323. ; See if the user wants to specify a handle rather than a straight pointer
  324. ;
  325. NoFldWidth:    cmp    al, '^'
  326.         jne     ChkFmtChars
  327.         mov    ah, al
  328.         lodsb                ;Skip "^" character
  329. ;
  330. ; Okay, process the format characters down here.
  331. ;
  332. ChkFmtChars:    and    al, 05fh        ;l.c. -> U.C.
  333.         cmp    al, 'D'
  334.         je    PrintDec
  335.         cmp    al, 'I'
  336.         je    PrintDec
  337.         cmp    al, 'C'
  338.         je    PrintChar
  339. ;
  340.         cmp    al, 'X'
  341.         jne    TryH
  342.         jmp    PrintHexWord
  343. ;
  344. TryH:        cmp    al, 'H'
  345.         jne    TryU
  346.         jmp    PrintHexByte
  347. ;
  348. TryU:        cmp    al, 'U'
  349.         jne    TryString
  350.         jmp    PrintUDec
  351. ;
  352. TryString:    cmp    al, 'S'
  353.         jne    TryLong
  354.         jmp    PrintString
  355. ;
  356. TryLong:    cmp    al, 'L'
  357.         jne    Default
  358. ;
  359. ; If we've got the "L" modifier, this is a long value to print, get the
  360. ; data type character as the next value:
  361. ;
  362.         lodsb
  363.         and    al, 05fh        ;l.c. -> U.C.
  364.         cmp    al, 'D'
  365.         je    JmpDec
  366.         cmp    al, 'I'
  367.         jne    TryLU
  368. JmpDec:        jmp    LongDec
  369. ;
  370. TryLU:        cmp    al, 'U'
  371.         jne    TryX
  372.         jmp    LongU
  373. ;
  374. TryX:        cmp    al, 'X'
  375.         jne    Default
  376.         jmp    LongX
  377. ;
  378. ;
  379. ;
  380. ; If none of the above, simply return without printing anything.
  381. ;
  382. Default:        ret
  383. ;
  384. ;
  385. ;
  386. ;
  387. ;
  388. ; Print a signed decimal value here.
  389. ;
  390. PrintDec:    call    GetPtr            ;Get next pointer into ES:BX
  391.         mov    ax, es:[bx]        ;Get value to print.
  392.         call    sl_ISize        ;Get the size of this guy.
  393.         sub    cx, ax                 ;Compute padding
  394.         mov    ax, es:[bx]        ;Retrieve value to print.
  395.         js    NoPadDec        ;Is CX negative?
  396.         cmp    dl, 0            ;Right justified?
  397.         jne    LeftJustDec
  398.         call    PrintPad        ;Print padding characters
  399.         call    PutIti            ;Print the integer
  400.         ret                ;We're done!
  401. ;
  402. ; Print left justified value here.
  403. ;
  404. LeftJustDec:    call    PutIti
  405.         call    PrintPad
  406.         ret
  407. ;
  408. ; Print non-justified value here:
  409. ;
  410. NoPadDec:    call    PutIti
  411.         ret
  412. ;
  413. ;
  414. ;
  415. ; Print a character variable here.
  416. ;
  417. PrintChar:    call    GetPtr            ;Get next pointer into ES:BX
  418.         mov    al, es:[bx]        ;Retrieve value to print.
  419.                 dec    cx
  420.         js    NoPadChar        ;Is CX negative?
  421.         cmp    dl, 0            ;Right justified?
  422.         jne    LeftJustChar
  423.         call    PrintPad        ;Print padding characters
  424.         call    PutIt            ;Print the character
  425.         ret                ;We're done!
  426. ;
  427. ; Print left justified value here.
  428. ;
  429. LeftJustChar:    call    PutIt
  430.         call    PrintPad
  431.         ret
  432. ;
  433. ; Print non-justified character here:
  434. ;
  435. NoPadChar:    call    PutIt
  436.         ret
  437. ;
  438. ;
  439. ;
  440. ;
  441. ; Print a hexadecimal word value here.
  442. ;
  443. PrintHexWord:    call    GetPtr            ;Get next pointer into ES:BX
  444.         mov    ax, es:[bx]        ;Get value to print.
  445.         sub    cx, 4            ;Compute padding
  446.         js    NoPadHexW        ;Is CX negative?
  447.         cmp    dl, 0            ;Right justified?
  448.         jne    LeftJustHexW
  449.         call    PrintPad        ;Print padding characters
  450.         call    PutItw            ;Print the hex value
  451.         ret                ;We're done!
  452. ;
  453. ; Print left justified value here.
  454. ;
  455. LeftJustHexW:    call    PutItw
  456.         call    PrintPad
  457.         ret
  458. ;
  459. ; Print non-justified value here:
  460. ;
  461. NoPadHexW:    call    PutItw
  462.         ret
  463. ;
  464. ;
  465. ;
  466. ;
  467. ; Print hex bytes here.
  468. ;
  469. ;
  470. PrintHexByte:    call    GetPtr            ;Get next pointer into ES:BX
  471.         mov    ax, es:[bx]        ;Get value to print.
  472.         sub    cx, 4            ;Compute padding
  473.         js    NoPadHexB        ;Is CX negative?
  474.         cmp    dl, 0            ;Right justified?
  475.         jne    LeftJustHexB
  476.         call    PrintPad        ;Print padding characters
  477.         call    PutIth            ;Print the hex value
  478.         ret                ;We're done!
  479. ;
  480. ; Print left justified value here.
  481. ;
  482. LeftJustHexB:    call    PutIth
  483.         call    PrintPad
  484.         ret
  485. ;
  486. ; Print non-justified value here:
  487. ;
  488. NoPadHexB:    call    PutIth
  489.         ret
  490. ;
  491. ;
  492. ;
  493. ; Output unsigned decimal numbers here:
  494. ;
  495. PrintUDec:    call    GetPtr            ;Get next pointer into ES:BX
  496.         mov    ax, es:[bx]        ;Get value to print.
  497.         call    sl_USize        ;Get the size of this guy.
  498.         sub    cx, ax                 ;Compute padding
  499.         mov    ax, es:[bx]        ;Retrieve value to print.
  500.         js    NoPadUDec        ;Is CX negative?
  501.         cmp    dl, 0            ;Right justified?
  502.         jne    LeftJustUDec
  503.         call    PrintPad        ;Print padding characters
  504.         call    PutItu            ;Print the integer
  505.         ret                ;We're done!
  506. ;
  507. ; Print left justified value here.
  508. ;
  509. LeftJustUDec:    call    PutItu
  510.         call    PrintPad
  511.         ret
  512. ;
  513. ; Print non-justified value here:
  514. ;
  515. NoPadUDec:    call    PutItu
  516.         ret
  517. ;
  518. ;
  519. ;
  520. ;
  521. ; Output a string here:
  522. ;
  523. PrintString:    call    GetPtr            ;Get next pointer into ES:BX
  524. ;
  525. ; Compute the length of the string:
  526. ;
  527.         push    di
  528.         push    cx
  529.         mov    cx, -1
  530.         mov    di, bx
  531.         mov    al, 0
  532.     repne    scasb
  533.         mov    ax, cx
  534.         neg    ax
  535.         dec    ax
  536.         dec    ax
  537.         pop    cx
  538.         pop    di
  539.         sub    cx, ax            ;Field width - String Length.
  540. ;
  541.         js    NoPadStr        ;Is CX negative?
  542.         cmp    dl, 0            ;Right justified?
  543.         jne    LeftJustStr
  544.         call    PrintPad        ;Print padding characters
  545.         call    Puts            ;Print the string
  546.         ret                ;We're done!
  547. ;
  548. ; Print left justified value here.
  549. ;
  550. LeftJustStr:    call    Puts
  551.         call    PrintPad
  552.         ret
  553. ;
  554. ; Print non-justified value here:
  555. ;
  556. NoPadStr:    call    Puts
  557.         ret
  558. GetFmtItem    endp
  559. ;
  560. ;
  561. ;
  562. ; Print a signed long decimal value here.
  563. ;
  564. LongDec:    call    GetPtr            ;Get next pointer into ES:BX
  565.         mov    ax, es:[bx]        ;Get value to print.
  566.         push    dx
  567.         mov    dx, es:2[bx]
  568.         call    sl_LSize        ;Get the size of this guy.
  569.         pop    dx
  570.         sub    cx, ax                 ;Compute padding
  571.         mov    ax, es:[bx]        ;Retrieve value to print.
  572.         js    NoPadLong        ;Is CX negative?
  573.         cmp    dl, 0            ;Right justified?
  574.         jne    LeftJustLong
  575.         call    PrintPad        ;Print padding characters
  576.         mov    dx, es:2[bx]        ;Get H.O. word
  577.         call    PutItL            ;Print the integer
  578.         ret                ;We're done!
  579. ;
  580. ; Print left justified value here.
  581. ;
  582. LeftJustLong:    push    dx
  583.         mov    dx, es:2[bx]        ;Get H.O. word
  584.         call    PutItL
  585.         pop    dx
  586.         call    PrintPad
  587.         ret
  588. ;
  589. ; Print non-justified value here:
  590. ;
  591. NoPadLong:    mov    dx, es:2[bx]        ;Get H.O. word
  592.         call    PutItl
  593.         ret
  594. ;
  595. ;
  596. ; Print an unsigned long decimal value here.
  597. ;
  598. LongU:        call    GetPtr            ;Get next pointer into ES:BX
  599.         mov    ax, es:[bx]        ;Get value to print.
  600.         push    dx
  601.         mov    dx, es:[bx]
  602.         call    sl_ULSize        ;Get the size of this guy.
  603.         pop    dx
  604.         sub    cx, ax                 ;Compute padding
  605.         mov    ax, es:[bx]        ;Retrieve value to print.
  606.         js    NoPadULong        ;Is CX negative?
  607.         cmp    dl, 0            ;Right justified?
  608.         jne    LeftJustULong
  609.         call    PrintPad        ;Print padding characters
  610.         mov    dx, es:2[bx]        ;Get H.O. word
  611.         call    PutItUL            ;Print the integer
  612.         ret                ;We're done!
  613. ;
  614. ; Print left justified value here.
  615. ;
  616. LeftJustULong:    mov    dx, es:2[bx]        ;Get H.O. word
  617.         call    PutItUL
  618.         call    PrintPad
  619.         ret
  620. ;
  621. ; Print non-justified value here:
  622. ;
  623. NoPadULong:    mov    dx, es:2[bx]        ;Get H.O. word
  624.         call    Putitul
  625.         ret
  626. ;
  627. ;
  628. ; Print a long hexadecimal value here.
  629. ;
  630. LongX:        call    GetPtr            ;Get next pointer into ES:BX
  631.         sub    cx, 8            ;Compute padding
  632.         js    NoPadXLong        ;Is CX negative?
  633.         cmp    dl, 0            ;Right justified?
  634.         jne    LeftJustXLong
  635.         call    PrintPad        ;Print padding characters
  636.         mov    ax, es:2[bx]        ;Get H.O. word
  637.         call    PutItw
  638.         mov    ax, es:[bx]
  639.         call    PutItw
  640.         ret                ;We're done!
  641. ;
  642. ; Print left justified value here.
  643. ;
  644. LeftJustxLong:    mov    ax, es:2[bx]        ;Get H.O. word
  645.         call    PutItw
  646.         mov    ax, es:[bx]        ;Get L.O. word
  647.         call    PutItw
  648.         call    PrintPad
  649.         ret
  650. ;
  651. ; Print non-justified value here:
  652. ;
  653. NoPadxLong:    mov    ax, es:2[bx]        ;Get H.O. word
  654.         call    PutItw
  655.         mov    ax, es:[bx]
  656.         call    PutItw
  657.         ret
  658. ;
  659. ;
  660. ;
  661. ;
  662. ; Puts- Outputs the zero terminated string pointed at by ES:BX.
  663. ;
  664. Puts        proc    near
  665. PutsLp:        mov    al, es:[bx]
  666.         cmp    al, 0
  667.         je    PutsDone
  668.         call    putIt
  669.         inc    bx
  670.         jmp    PutsLp
  671. ;
  672. PutsDone:    ret
  673. Puts        endp
  674. ;
  675. ;
  676. ;
  677. ;
  678. ;
  679. ; PrintPad-    Prints padding characters.  Character to print is in DH.
  680. ;        We must print it CX times.  CX must be greater than zero.
  681. ;
  682. PrintPad    proc    near
  683.         push    ax
  684.         mov    al, dh
  685.         jcxz    NoPadding
  686. PPLoop:        call    PutIt
  687.         loop    PPLoop
  688. NoPadding:    pop    ax
  689.         ret
  690. PrintPad    endp
  691. ;
  692. ;
  693. ;
  694. ;
  695. ;
  696. ; GetPtr- Grabs the next pointer which DS:DI points at and returns this
  697. ;      far pointer in ES:BX.
  698. ;
  699. GetPtr        proc    near
  700.         les    bx, [di]
  701.         add    di, 4
  702. ;
  703. ; See if this is a handle rather than a pointer.
  704. ;
  705.         cmp    ah, '^'
  706.         jne    NotHandle
  707.         les    bx, es:[bx]
  708. NotHandle:    ret
  709. GetPtr        endp
  710. ;
  711. ;
  712. ;
  713. ;
  714. ;
  715. ; GetDecVal-    Converts the string of decimal digits in AL and [SI] into
  716. ;        an integer and returns this integer in CX.
  717. ;
  718. GetDecVal    proc    near
  719.         push    dx
  720.         dec    si
  721.         xor    cx, cx
  722. DecLoop:    lodsb
  723.         cmp    al, '0'
  724.         jb    NoMore
  725.         cmp    al, '9'
  726.         ja    NoMore
  727.         and    al, 0fh
  728.         shl    cx, 1            ;Compute CX := CX*10 + al
  729.         mov    dx, cx
  730.         shl    cx, 1
  731.         shl    cx, 1
  732.         add    cx, dx
  733.         add    cl, al
  734.         adc    ch, 0
  735.         jmp    DecLoop
  736. NoMore:        pop    dx
  737.         ret
  738. GetDecVal    endp
  739. ;
  740. ;
  741. ; PutItL - outputs the unsigned long value in AX to the string.
  742. ;
  743. PutItL        proc
  744.         push    bx
  745.         push    cx
  746.         push    es
  747.         push    si
  748.         push    ds
  749.         push    di
  750.         call    sl_ltoam
  751.         call    ConCat
  752.         pop    di
  753.         pop    ds
  754.         pop    si
  755.         pop    es
  756.         pop    cx
  757.         pop    bx
  758.         ret
  759. PutItL        endp
  760. ;
  761. ;
  762. ; PutItUL - outputs the unsigned long value in AX to the string.
  763. ;
  764. PutItUL        proc
  765.         push    bx
  766.         push    cx
  767.         push    es
  768.         push    si
  769.         push    ds
  770.         push    di
  771.         call    sl_ultoam
  772.         call    ConCat
  773.         pop    di
  774.         pop    ds
  775.         pop    si
  776.         pop    es
  777.         pop    cx
  778.         pop    bx
  779.         ret
  780. PutItUL        endp
  781. ;
  782. ;
  783. ;
  784. ; PutItw - outputs the hexadecimal value in AX to the string.
  785. ;
  786. PutItw        proc
  787.         push    bx
  788.         push    cx
  789.         push    es
  790.         push    si
  791.         push    ds
  792.         push    di
  793.         call    sl_wtoam
  794.         call    ConCat
  795.         pop    di
  796.         pop    ds
  797.         pop    si
  798.         pop    es
  799.         pop    cx
  800.         pop    bx
  801.         ret
  802. PutItw        endp
  803. ;
  804. ;
  805. ; PutIth - outputs the hexadecimal value in AL to the string.
  806. ;
  807. PutIth        proc
  808.         push    bx
  809.         push    cx
  810.         push    es
  811.         push    si
  812.         push    ds
  813.         push    di
  814.         call    sl_htoam
  815.         call    ConCat
  816.         pop    di
  817.         pop    ds
  818.         pop    si
  819.         pop    es
  820.         pop    cx
  821.         pop    bx
  822.         ret
  823. PutIth        endp
  824. ;
  825. ;
  826. ;
  827. ; PutIti - outputs the integer in AX to the string.
  828. ;
  829. PutIti        proc
  830.         push    bx
  831.         push    cx
  832.         push    es
  833.         push    si
  834.         push    ds
  835.         push    di
  836.         call    sl_itoam
  837.         call    ConCat
  838.         pop    di
  839.         pop    ds
  840.         pop    si
  841.         pop    es
  842.         pop    cx
  843.         pop    bx
  844.         ret
  845. PutIti        endp
  846. ;
  847. ;
  848. ; PutItu - outputs the unsigned integer in AX to the string.
  849. ;
  850. PutItu        proc
  851.         push    bx
  852.         push    cx
  853.         push    es
  854.         push    si
  855.         push    ds
  856.         push    di
  857.         call    sl_utoam
  858.         call    ConCat
  859.         pop    di
  860.         pop    ds
  861.         pop    si
  862.         pop    es
  863.         pop    cx
  864.         pop    bx
  865.         ret
  866. PutItu        endp
  867. ;
  868. ;
  869. ;
  870. ; ConCat- Concatenates the string pointed at by ES:DI to the end of our
  871. ;      formatted string.
  872. ;
  873. ConCat        proc    near
  874.         push    di
  875.         lds    si, StdGrp:aptr
  876.         mov    bx, StdGrp:aindex
  877.         sub    di, bx
  878. PILp:        mov    al, es:[di][bx]
  879.         mov    [si][bx], al
  880.         inc    bx
  881.         cmp    al, 0
  882.         jne    PILp
  883.         dec    bx
  884.         mov    StdGrp:aindex, bx
  885.         pop    di
  886.         call    sl_free
  887.         ret
  888. ConCat        endp
  889. ;
  890. ; PutIt writes the character in AL to the string buffer area.
  891. ;
  892. PutIt        proc
  893.         push    es
  894.         push    si
  895.         push    bx
  896.         mov    bx, StdGrp:aindex
  897.         les    si, StdGrp:aptr
  898.         mov    es:[si][bx], al
  899.         mov    byte ptr es:1[si][bx], 0
  900.         inc     StdGrp:aindex
  901.         pop    bx
  902.         pop    si
  903.         pop    es
  904.         ret
  905. PutIt        endp
  906. ;
  907. stdlib        ends
  908.         end
  909.